package com.ty.controller.admin;

import java.util.List;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import com.ty.entity.SysAdmin;
import com.ty.entity.SysMenus;
import com.ty.service.MenusService;

@Controller
@RequestMapping("/admin/index")
public class IndexController {

	@Autowired
	private MenusService mensService;
	
	@RequiresPermissions("admin:index:index")
	@RequestMapping("/index")
	public String index(ModelMap model) {
		//获取当前用户的菜单地址信息
		SysAdmin sysAdmin=(SysAdmin) SecurityUtils.getSubject().getSession().getAttribute("user");
		List<SysMenus> menusList= mensService.selectByUserMenus(sysAdmin);
		model.put("menusList",menusList);
		return "admin/index/index";
	}
	
	@RequiresRoles(value="role1")
	@RequiresPermissions("admin:index:roles")
	@RequestMapping("/roles")
	public String roles() {
		return "admin/index/roles";
	}
}
